package com.leoman.dao;

import com.leoman.entity.LeaveMessage;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

/**
 * LeaveMessageDao
 * Created by 涂奕恒 on 2016/11/23 0023 下午 3:43.
 */
public interface LeaveMessageDao extends JpaRepository<LeaveMessage, Integer>, JpaSpecificationExecutor<LeaveMessage> {

    @Query("select a from LeaveMessage a where a.sourceUser.id = ?1 and a.isRead = 0")
    List<LeaveMessage> findToMyListNoRead(Integer userId);

    @Query("select a from LeaveMessage a where a.sourceUser.id = ?1")
    List<LeaveMessage> findToMyList(Integer userId);
}